package com.woke.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.woke.data.Datas_bankedcard;
import com.zhongcai.online.R;

import java.util.ArrayList;
import java.util.List;

public class Mybanklistbadter extends BaseAdapter {
	private LayoutInflater mInflater;
	private List<Datas_bankedcard> datalist;

	public Mybanklistbadter(LayoutInflater minflater, ArrayList<Datas_bankedcard> datalsit) {
		this.mInflater = minflater;
		this.datalist = datalsit;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return datalist == null ? 0 : datalist.size ();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	class Holder {
		TextView mTbankname;
		TextView mTbankcarno;
		TextView mTcardtype;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Holder holder = null;
		if (convertView == null) {
			holder = new Holder ();
			convertView = mInflater.inflate (R.layout.item_adater_mybank, null);
			holder.mTbankname = (TextView) convertView.findViewById (R.id.item_myblind_title);
			holder.mTbankcarno = (TextView) convertView.findViewById (R.id.item_myblind_cardno);
			holder.mTcardtype = (TextView) convertView.findViewById (R.id.item_myblind_cardtype);
			convertView.setTag (holder);
		} else {
			holder = (Holder) convertView.getTag ();
		}

		Datas_bankedcard list = datalist.get (position);
//		if(list.brname.endsWith("")){
//			holder.mTbankname.setText("����");
//		}else{
		holder.mTbankname.setText (list.getBrname ());
//		}
		holder.mTbankcarno.setText (list.cardno.substring (0, 4) + "    " + "***" + "    " + "***" + "    " + "***" + "    " + list.cardno
				.substring (list.cardno.length () - 3, list.cardno.length ()));
		if (list.type.equals ("0")) {
			holder.mTcardtype.setText ("信用卡");
		} else {
			holder.mTcardtype.setText ("储蓄卡");
		}

		return convertView;
	}

}
